package study.java.jdk.jdk8._1_stream.intermediate;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Arrays;
import java.util.IntSummaryStatistics;
import java.util.List;

@Slf4j
public class mapToInt_Test {

    List<Integer> src = Arrays.asList(1, 2, 3, 4);
    List<String> str = Arrays.asList("1","2","3");

    @Test
    public void test1() {
        Integer sum = src.stream()
                .mapToInt(e -> e)
                .sum();
        log.info("sum= {}", sum);
    }

    @Test
    public void test2() {
        IntSummaryStatistics sum = src.stream()
                .mapToInt(e -> e)
                .summaryStatistics();
        log.info("count= {}", sum.getCount());
        log.info("min= {}", sum.getMin());
        log.info("max= {}", sum.getMax());
        log.info("sum= {}", sum.getSum());
        log.info("avgs= {}", sum.getAverage());
    }
}
